<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/21
 * Time: 11:45
 */
namespace Publish\Controller;
use Common\Controller\HomebaseController;
class HomepageController extends HomebaseController{
	protected $terms_model;
	protected $term_relationships_model;
	protected $video_model;
	protected $person_model;
	function _initialize() {
		parent::_initialize();
		$this->terms_model=D("Publish/SystemTerms");
		$this->term_relationships_model = D("Publish/SystemTermRelationships");
		$this->video_model=D('Publish/PubVideo');
		$this->person_model=D('Publish/PubPerson');
	}
	public function index(){
		/* 查出所有的一级分类*/
		$first=$this->terms_model
			->field('term_id,name')
			->where(array('parent'=>0))
			->where(array('term_id'=>array('NEQ','72')))
			->select();
		for($i=0;$i<count($first);$i++){
			$list=$this->terms_model
				->where(array('parent'=>$first[$i]['term_id']))
				->field('name,term_id')
				->select();
			foreach($list as $k=>$v){
				$newarr[$i]['name']=$first[$i]['name'];
				$newarr[$i]['term_id']=$first[$i]['term_id'];
				$newarr[$i]['term_son']['term_id'][]=$v['term_id'];
				$newarr[$i]['term_son']['name'][]=$v['name'];
			}
		}
		$this->assign('first',$newarr);
		$this->assign('two',$first['asd']);
		$this->display();
	}
}